﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
public partial class aspnet_admin_bock_keyWord_CX_keyWord_Edit : System.Web.UI.Page
{
    /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
    public TongUse TextData = new TongUse();


    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();


    /// <summary>
    /// id
    /// </summary>
  public  string id = "";

    /// <summary>
    /// 爱问的实列
    /// </summary>
    Tong.IAsk.IaskDataOrstr Ask = new Tong.IAsk.IaskDataOrstr();

    protected void Page_Load(object sender, EventArgs e)
    {

        if (IsPostBack)
        {
            try
            {
                id = Request.QueryString["id"].Trim();

                PageSave(int.Parse(id));
            }
            catch
            {
                Response.Write("");
            }
        }

            PageLand_First();
     
    }

    /// <summary>
    /// 加载时出现的东东
    /// </summary>
    protected void PageLand_First()
    {
        try
        {
            id = Request.QueryString["id"].Trim();
            int.Parse(id);
            MyDt = TextData.SqlataSet("select * from [ask_query] where ask_query_id  =" + id + "").Tables[0];

            ask_query_name.Text = MyDt.Rows[0]["ask_query_name"].ToString().Trim();
            ask_query_cont.Text = MyDt.Rows[0]["ask_query_cont"].ToString().Trim();
            ask_query_state.Value = MyDt.Rows[0]["ask_query_state"].ToString().Trim();
            ask_query_hit.Text = MyDt.Rows[0]["ask_query_hit"].ToString().Trim();
            ask_query_Sort .Text = MyDt.Rows[0]["ask_query_Sort"].ToString().Trim();
            ask_query_feng.Text = MyDt.Rows[0]["ask_query_feng"].ToString().Trim();
            askuser_id.Text = Ask.IaskGetUseTable(MyDt.Rows[0]["askuser_id"].ToString().Trim()).Rows[0][2].ToString();
            if (Ask.是否为推荐问题(id))
            {
                ask_query_commend.Checked = true;
            }
        }
        catch
        {
            tt.Text = "不存在的问题";
            
        }
    }


    protected void PageSave(int id)
    {

        try
        {
            string TuijiaNQuestion="0";//推荐问题
            if (ask_query_commend.Checked == true)
            {
                TuijiaNQuestion = "1";
            }

            int.Parse(ask_query_Sort .Text.Trim());
            if (ask_query_Sort.Text != "" && ask_query_cont.Text.Length <3500)
            {
                if (int.Parse(ask_query_Sort .Text.Trim()) <= 99999)
                {
                    TextData.SqlDataSave("update [ask_query] Set  ask_query_cont='" + Server.HtmlEncode(ask_query_cont.Text.Trim()) + "',ask_query_commend="+TuijiaNQuestion+",ask_query_Sort=" + int.Parse(ask_query_Sort.Text.Trim()) + " where ask_query_id=" + id);

                    tt.Text = "更新用户" + ask_query_name.Text + "成功";
                }
                else
                {
                    tt.Text = "排序超出范围";
                }
            }
            else
            {
                tt.Text = "输入的问题为空或超过250个或不存在此问题";

            }
        }
        catch
        {
            tt.Text = "排序超出范围";
        }

    }
    



}
